package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.entity.Page.NursingProjectPage;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/nursing_project")
@Api(tags = "护理项目接口")
public class NursingProjectController extends BaseController {

    @Autowired
    private NursingProjectService nursingProjectService;

    @GetMapping()
    @ApiOperation(value = "分页查询护理项目", notes = "传入护理项目分页")
    public ResponseResult<PageResponse<NursingProjectVo>> queryNursingProject(
            @ApiParam(value = "护理项目分页对象", required = true)  NursingProjectPage nursingProjectPage){
        PageResponse<NursingProjectVo> pageResponse= nursingProjectService.queryNusingProject(nursingProjectPage);
        return success(pageResponse);
    }

    @PostMapping()
    @ApiOperation(value = "新增护理项目",notes = "传入护理项目对象NursingProjectDto")
    public ResponseResult insertNursingProject(@ApiParam(value = "护理项目对象" ,required = true) @RequestBody NursingProjectDto nursingProject){
        int index=nursingProjectService.insertNursingProject(nursingProject);
        return toAjax(index);
    }
    @GetMapping("/{id}")
    @ApiOperation(value = "通过id查询护理项目",notes = "id")
    public ResponseResult<NursingProjectVo> queryNursingProjectById(
            @ApiParam(value = "id",required = true) @PathVariable("id") Integer id){
        NursingProjectVo nursingProjectVo=nursingProjectService.queryNusingProjectById(id);

        return success(nursingProjectVo);
    }


    @PutMapping()
    @ApiOperation(value = "修改护理项目",notes = "传入护理项目对象NursingProjectDto")
    public ResponseResult updateNursingProject(@ApiParam(value = "护理项目对象" ,required = true) @RequestBody NursingProjectDto nursingProject){
        int index=nursingProjectService.updateNursingProject(nursingProject);
        return toAjax(index);
    }


}
